<template>
    <!--还款数据-->
    <div class="content_panel project_modules">
        <!-- 结算中心 -->
        <settlement-center
            v-if="activeTab === 'settlementCenter'"
            :active-tab="activeTab"
            :companyList="companyList"
            :domainList="domainList"
            @updateActiveTab="updateActiveTab">
        </settlement-center>
        <!-- 余额预警 -->
        <balance-warning
            v-if="activeTab === 'balanceWarning'"
            :active-tab="activeTab"
            :companyList="companyList"
            :domainList="domainList"
            @updateActiveTab="updateActiveTab">
        </balance-warning>
    </div>
</template>

<script>
    import settlementCenter from './components/settlement-center';
    import balanceWarning from './components/balance-warning';

    let that = null;
    export default {
        name: 'report-settlementCenter',
        components: {
            settlementCenter,
            balanceWarning
        },
        data() {
            return {
                activeTab: 'settlementCenter',
                companyList: [],
                domainList: [],
            };
        },
        watch: {

        },
        methods: {
             // 获取列表数据
            updateActiveTab(val) {
                if (val) {
                    this.activeTab = val;
                }
            },
            //获取公司列表
            getCompanyList() {
                const params = {
                    status: 1,
                    pageNum: 1,
                    pageSize: 100000
                };
                this.$api.systemManage.getCompanyList(params).then((res) => {
                    const {status, data, error} = res;
                    if ('1' === status && error === '00000000') {
                        this.companyList = data.companyList;
                    }
                });
            },
            //获取domain列表
            getDomainList() {
                const params = {
                    username: '',
                    id: '',
                    cpId: '',
                    status: 1,
                    pageNum: 1,
                    pageSize: 10000
                };
                this.$api.systemManage.getUserCompanyList(params).then((res) => {
                    const {status, data, error} = res;
                    if ('1' === status && error === '00000000') {
                        this.domainList = data.userList || [];
                    }
                });
            },
        },
        created() {
            that = this;
            this.getCompanyList();
            this.getDomainList();
        },
    };
</script>

<style lang="scss">

</style>
